﻿Imports System.Data
Imports System.Data.SqlClient
Public Class CargoDatos

    Function obtenerCargos() As DataSet
        Dim conex As New Conexion
        Dim coneccion As New SqlConnection
        Dim dt As New DataTable
        Dim ds As New DataSet
        Try
            coneccion = conex.conectar()
            coneccion.Open()

            Dim query As String = "SELECT CAR_Codigo, CAR_Descripcion " &
                                  "FROM Cargo " &
                                  "WHERE CAR_Activo = '1'"

            Dim adapter As New SqlDataAdapter(query, coneccion)
            adapter.Fill(ds)

            dt = ds.Tables(0)
            Dim row As DataRow = dt.NewRow()
            row.Item("CAR_Codigo") = 0
            row.Item("CAR_Descripcion") = "Seleccionar..."
            dt.Rows.InsertAt(row, 0)
        Catch e As Exception
            ds = Nothing
        Finally
            coneccion.Close()
        End Try

        Return ds
    End Function

End Class
